package com.tsunami.security.uaa.component;

import com.tsunami.utils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @Classname MD5PasswordEncoder
 * @Description TODO
 * @Date 2021-11-19 10:06
 * @Created by lx
 */
public class MD5PasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence charSequence) {
        return MD5.encrypt(charSequence.toString());
    }

    @Override
    public boolean matches(CharSequence charSequence, String encodedPassword) {
        return encodedPassword.equals(MD5.encrypt(charSequence.toString()));
    }

    public static void main(String[] args) {
        System.out.println(MD5.encrypt("123456"));
    }
}
